'''
    承运人信息流程测试
'''

import pytest
import logging
import allure
import utils.allure_step as allure_step
from utils.sele_Util import sele_Util
from time import sleep

logger = logging.getLogger()
sele_util = sele_Util('Chrome')


@pytest.fixture(scope='module', autouse=True)
def flow03_fixture(url_fixture):
    sele_util.open(url_fixture['Url'])
    yield
    sleep(3)
    sele_util.quit()


@pytest.fixture(scope='module', autouse=True)
def execl_fixture():
    file_url = 'data/TMS/承运人信息测试.xlsx'
    yield file_url


@allure.suite('客户信息模块功能：登陆+新增司机')
class TestFlow03:

    # 测试登录流程
    @allure.title('登录测试')
    @allure.story('进行登录测试')
    def test01_login(self, execl_fixture):
        logger.info('开始登录测试')
        sheet_name = '登录'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('新增司机测试')
    @allure.story('进行新增司机测试')
    def test02_create_driver(self, execl_fixture):
        logger.info('开始新增司机测试')
        sheet_name = '新增司机'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('新增收款人测试')
    @allure.story('进行新增收款人测试')
    def test03_create_payee(self, execl_fixture):
        logger.info('开始新增收款人测试')
        sheet_name = '新增收款人'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('操作司机测试')
    @allure.story('操作司机测试')
    def test04_operation_driver(self, execl_fixture):
        logger.info('开始操作司机测试')
        sheet_name = '操作司机'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('新增车辆测试')
    @allure.story('新增车辆测试')
    def test05_create_car(self, execl_fixture):
        logger.info('开始新增车辆测试')
        sheet_name = '新增车辆'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('操作车辆测试')
    @allure.story('操作车辆测试')
    def test06_operation_car(self, execl_fixture):
        logger.info('开始操作车辆测试')
        sheet_name = '操作车辆'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('承运商管理测试')
    @allure.story('承运商管理测试')
    def test07_management_carrier(self, execl_fixture):
        logger.info('开始承运商管理测试')
        sheet_name = '承运商管理'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)

    @allure.title('删除司机车辆收款人测试')
    @allure.story('删除司机车辆收款人测试')
    def test07_management_carrier(self, execl_fixture):
        logger.info('开始删除司机车辆收款人测试')
        sheet_name = '删除司机车辆收款人'
        allure_step.service(sele=sele_util, file_url=execl_fixture, sheet_name=sheet_name)
